<?php

namespace mpend\modules\trade\models;

use Yii;
use common\models\shop\ShopOrder;
use common\models\member\MemberBond;

/**
 * Description of Constants
 *
 * @author emhome
 */
trait BizOrderModelTrait {

    /**
     * @inheritdoc
     */
    protected function shop($id) {
        $model = ShopOrder::findOne([
            'id' => $id,
            'status' => [ShopOrder::STATUS_DEFAULT, ShopOrder::STATUS_ACTIVE],
        ]);
        if ($model && !$model->getIsExpired()) {
            return $model;
        }
        return null;
    }

    /**
     * @inheritdoc
     */
    protected function bond($id) {
        $model = MemberBond::findOne([
            'id' => $id,
            'status' => [MemberBond::STATUS_DEFAULT, MemberBond::STATUS_ACTIVE],
        ]);
        if ($model && !$model->getIsExpired()) {
            return $model;
        }
        return null;
    }

}
